<template>
	<view class="bi-car-driver-adjust" @click="handleClick">
		<slot></slot>
	</view>
</template>

<script>
import { buildUrl } from '@/utils/url'
import { unique } from '@/utils/string'
import Event from '@/utils/event.js'
	
export default {
	name: 'BiCarDriverAdjust',
	props: {
		carId: {
			type: String,
			required: true
		},
		carPlate: {
			type: String
		},
		carNumber: {
			type: String
		}
	},
	created () {
		this.id = unique('car_driver_adjust')
		Event.on(this.id, ({ selection }) => {
			this.$emit('change', {
				selection
			})
		})
	},
	methods: {
		handleClick () {
			uni.navigateTo({
				url: buildUrl('/packages/car/car-driver-adjust/car-driver-adjust', {
					carId: this.carId,
					title: `${this.carPlate || ''} ${this.carNumber}`,
					eventName: this.id
				})
			})
		}
	},
	beforeDestroy () {
		Event.off(this.id)
	}
}
</script>

<style>
</style>